﻿using Dapper;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using zzh_the_Visual_Studio.Models;

namespace zzh_the_Visual_Studio.DAL
{
    public class DAL_Login
    {
        private MySqlConnection mySqlConnection = new MySqlConnection(ConfigHelper.Configuration["MySQLConnectionString"]);
        //查询、登录管理员账号
        public List<manage> postManage(manage a)
        {
            var list = mySqlConnection.Query<manage>("SELECT * FROM manage where m_number=@m_number and password=@password",a).ToList();
            return list;
        }
        //查询、登录学生账号
        public List<dell> postStudent(dell b)
        {
            var list = mySqlConnection.Query<dell>("SELECT * FROM dell where s_number=@s_number and password=@password",b).ToList();
            return list;
        }
        //查询、登录教师账号 
        public List<dell> postTeacher(dell c)
        {
            var list = mySqlConnection.Query<dell>("SELECT * FROM dell where t_number=@t_number and `password`=@password",c).ToList();
            return list;
        }
        //注册学生账号
        public int createStudents(dell s)
        {
            return mySqlConnection.Execute("INSERT INTO dell (s_number,`password`) VALUES (@s_number,@password)",s);
        }
        //注册教师账号
        public int createTeachers(dell t)
        {
            return mySqlConnection.Execute("INSERT INTO dell (t_number,password) VALUES (@t_number,@password)", t);

        }
    }
}